package com.lpf.xpermission;

import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.util.Log;
import android.widget.Toast;

import androidx.core.content.ContextCompat;

import com.lpf.xypermission.annotation.PermissionCanceled;
import com.lpf.xypermission.annotation.PermissionDenied;
import com.lpf.xypermission.annotation.PermissionNeed;

/**
 * Created by lpf on 2022/6/6 0006
 * Describe:
 */
public class PermissionUtil {


    private String tag = "PermissionUtil";

    public static PermissionUtil getInstance() {
        return InstanceHolder.permissionUtil;
    }

    static class InstanceHolder {
        static PermissionUtil permissionUtil = new PermissionUtil();
    }

    @PermissionNeed(permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE}, requestCode = 20)
    public void writeFile() {


    }

    @PermissionCanceled
    public void permissionCanceled(int requestcode) {

        if (requestcode == 20) {
            Log.e(tag, "permissionCanceled>>>>>>PermissionUtil");
        }

    }

    @PermissionDenied
    public void permissionDenied(int requestcode) {

        if (requestcode == 20) {
            Log.e(tag, "permissionDenied>>>>>>PermissionUtil");
        }

    }


}
